package com.master5.grocerylist.deprecated;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/api/employee")
public class EmployeeResource {
	EmployeeDao dao = new EmployeeDao();

	/*
	@GET
	@Produces("application/json")
	@Path("/employee/{employeeEmail}/")
	public ArrayList<Employee> getEmployee(
			@PathParam("employeeEmail") @DefaultValue("") String email) {
		System.out.println(email);
		// dummy code
		if (email.isEmpty()) {
			Employee emp = new Employee();
			emp.setEmail(email);
			emp.setFirstName("John");
			emp.setLastName("Doe");
			employees.add(emp);
		}
		return employees;
	}
	*/
	
	@GET
	@Produces(MediaType.TEXT_PLAIN)
	@Path("/create/{employee_name}/{employee_email}/{employee_salary}/")
	public String createEmployee(@PathParam("employee_name") String name, 
			@PathParam("employee_email") String email, 
			@PathParam("employee_salary") int salary) {
		if (dao.createEmployee(name, email, salary))
			return "Success";
		return "Failure";
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	@Path("/findAll")
	public List<Employee> findAll() {
		return dao.findAll();
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	@Path("/findById/{id}/")
	public Employee findById(@PathParam("id") int id) {
		return dao.findById(id);
	}
	
	

}